package challenge.计挑赛._2022区域赛;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * @author 挚爱之夕
 * @version 1.0
 * @implSpec
 *
 * @since 2022 - 12 - 29 - 15:18
 */
public class C_层序求后序 {
}

class C {
    static class TreeNode{
        public char val;
        public TreeNode left;
        public TreeNode right;
        public TreeNode(){

        }
        public TreeNode(char t) {
            val = t;
        }
    }
    static void dfs(TreeNode root) {
        if(root == null) return;
        if(root.left != null) {
            dfs(root.left);
        }
        if(root.right != null) {
            dfs(root.right);
        }
        System.out.print(root.val);
    }
    static int n;
    static TreeNode root;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int len = line.length();
        root = new TreeNode(line.charAt(0));
        TreeNode p = root;
        Deque<TreeNode> queue = new LinkedList<TreeNode>();
        queue.offer(p);
        int cur = 0, curCnt = 1;
        char a, b;
        while(!queue.isEmpty()) {
            TreeNode t = queue.poll();
            if(cur + 1 >= len) {
                break;
            }
            a = line.charAt(cur + 1);
            if(a != '#') {
                t.left = new TreeNode(a);
            }
            if(cur + 2 >= len) {
                break;
            }
            b = line.charAt(cur + 2);
            if(b != '#') {
                t.right = new TreeNode(b);
            }
            cur += 2;
            if(t.left != null) queue.offer(t.left);
            if(t.right != null) queue.offer(t.right);
        }
        dfs(root);
    }

}